*
* Here’s a simple example:
* |[<!-- language="C" -->
- * GtkWidget *main_app_window; // Window the dialog should show up on
+ * GtkWindow *main_app_window; // Window the dialog should show up on
* GtkWidget *dialog;
* GtkDialogFlags flags = GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT;
* dialog = gtk_dialog_new_with_buttons ("My dialog",
* ## Simple GtkDrawingArea usage
*
* |[<!-- language="C" -->
- * void
- * draw_function (GtkDrawingArea *area, cairo_t *cr,
- * int width, int height,
- * gpointer data)
+ * static void
+ * draw_function (GtkDrawingArea *area,
+ * cairo_t *cr,
+ * int width,
+ * int height,
+ * gpointer data)
* {
* GdkRGBA color;
* GtkStyleContext *context;
* cairo_fill (cr);
* }
*
- * void main (int argc, char **argv)
+ * int
+ * main (int argc, char **argv)
* {
* gtk_init ();
*
* gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (area),
* draw_function,
* NULL, NULL);
- *
+ * return 0;
* }
* ]|
*
* ## Forcing entry to uppercase.
*
* |[<!-- language="C" -->
- * #include <ctype.h>;
+ * #include <ctype.h>
*
* void
* insert_text_handler (GtkEditable *editable,
* file and is saving it for the first time, do not call this function.
* Instead, use something similar to this:
* |[<!-- language="C" -->
- * if (document_is_new)
- * {
- * // the user just created a new document
- * gtk_file_chooser_set_current_folder (chooser, default_file_for_saving);
- * gtk_file_chooser_set_current_name (chooser, "Untitled document");
- * }
- * else
- * {
- * // the user edited an existing document
- * gtk_file_chooser_set_file (chooser, existing_file);
- * }
+ * static void
+ * prepare_file_chooser (GtkFileChooser *chooser,
+ * GFile *existing_file)
+ * {
+ * gboolean document_is_new = (existing_file == NULL);
+ *
+ * if (document_is_new)
+ * {
+ * GFile *default_file_for_saving = g_file_new_for_path ("./out.txt");
+ * // the user just created a new document
+ * gtk_file_chooser_set_current_folder (chooser, default_file_for_saving, NULL);
+ * gtk_file_chooser_set_current_name (chooser, "Untitled document");
+ * g_object_unref (default_file_for_saving);
+ * }
+ * else
+ * {
+ * // the user edited an existing document
+ * gtk_file_chooser_set_file (chooser, existing_file, NULL);
+ * }
+ * }
* ]|
*
* Returns: Not useful.
*
* button = gtk_file_chooser_button_new (_("Select a file"),
* GTK_FILE_CHOOSER_ACTION_OPEN);
- * gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (button), cwd);
+ * gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (button), cwd, NULL);
* g_object_unref (cwd);
* }
* ]|
*
* |[<!-- language="C" -->
* static void
- * on_response (GtkNativeDialog *dialog,
+ * on_response (GtkNativeDialog *native,
* int response)
* {
* if (response == GTK_RESPONSE_ACCEPT)
*
* |[<!-- language="C" -->
* static void
- * on_response (GtkNativeDialog *dialog,
+ * on_response (GtkNativeDialog *native,
* int response)
* {
* if (response == GTK_RESPONSE_ACCEPT)
* {
- * GtkFileChooser *chooser = GTK_FILE_CHOOSER (dialog);
+ * GtkFileChooser *chooser = GTK_FILE_CHOOSER (native);
* GFile *file = gtk_file_chooser_get_file (chooser);
*
* save_to_file (file);
* chooser = GTK_FILE_CHOOSER (native);
*
* if (user_edited_a_new_document)
- * gtk_file_chooser_set_current_name (chooser,
- * _("Untitled document"));
+ * gtk_file_chooser_set_current_name (chooser, _("Untitled document"));
* else
- * gtk_file_chooser_set_filename (chooser,
- * existing_filename);
+ * gtk_file_chooser_set_file (chooser, existing_file, NULL);
*
* g_signal_connect (native, "response", G_CALLBACK (on_response), NULL);
* gtk_native_dialog_show (GTK_NATIVE_DIALOG (native));